
let tools = {}


/**
 * 从一个对象复制属性到另外一个对象上 业务场景是修改内容时，服务器返回字段内容比较多
 * targetData 是将要用来设置新属性的对象；设置值时只设置两者键值相同内容
 * fromObject 是数据来源
 */
tools.copyPropertyToData = (targetData, fromObject) => {
    let keys = Object.keys(targetData);
    for (var i = 0; i < keys.length - 1; i++) {
        let key = keys[i];
        if (fromObject.hasOwnProperty(key)) {
            targetData[key] = fromObject[key];
        }
    }
}

/**
 * 传入时间对象
 */
tools.formatTimestamp = function(date) {
    if(date == null || date == "")
        return "";
	return date.toLocaleDateString().replace(/\//g, "-") + " " + date.toTimeString().substr(0, 8);
}

export default tools;